home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Stacks / Updates⁄New / TEXAS for BMUG / C progs / TEXAS XFCNs ƒ / mergeIndicesXFCN ƒ / init_everything.z1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-12-30  |  1.9 KB  |  84 lines  |  [TEXT/KAHL]

  1. /* routine to initialize stuff.... for the mergeIndices project
  2.  * ^z 871203-... revised 871230 for XFCN use... return 1 if succeeds,
  3.  * 0 on error....
  4.  *
  5.  * Note that the zbufsiz is defined so that it is an exact multiple of
  6.  * the size of a key record and a ptr record....important to do so!
  7.  */
  8.  
  9. #include "mergeIndices.z.h"
  10.  
  11. extern WindowRecord w_record;
  12. extern WindowPtr info_window;
  13. extern char *buf[3][2], *bufp[3][2];
  14. extern long bufcount[3][2], zbufsiz;
  15. extern int x0, y0;
  16.  
  17. int init_everything (paramPtr)
  18.   XCmdBlockPtr paramPtr;
  19.   {
  20.     int i, j;
  21.     Str255 string;
  22.     Rect b_rect;
  23.     Ptr testzbufsiz;
  24.  
  25.     if (paramPtr->paramCount != 3)
  26.       {
  27.           SysBeep (10);
  28.           return (0);
  29.       }
  30.     x0 = atol (*(paramPtr->params[0]));
  31.     y0 = atol (*(paramPtr->params[1]));
  32.     zbufsiz = atol (*(paramPtr->params[2]));
  33.     zbufsiz /=  6;
  34.     zbufsiz = zbufsiz - zbufsiz % (sizeof(KEY_REC) * sizeof(long));
  35.     
  36.     b_rect.top = 30 + y0;
  37.     b_rect.left = 12 + x0;
  38.     b_rect.bottom = 52 + y0;
  39.     b_rect.right = 500 + x0;
  40.     info_window = NewWindow (&w_record, &b_rect, "\p", (Boolean)1, dBoxProc,
  41.         (WindowPtr)-1, (Boolean)0, (long)0);
  42.     ShowWindow (info_window);
  43.     SetPort (info_window);
  44.     TextFont (0);
  45.     give_msg ("\pWelcome to mergeIndices by ^z!");
  46.       
  47.     if (zbufsiz < sizeof(KEY_REC) * sizeof(long))
  48.       {
  49.         give_msg ("\pBad choice for buffer size -- too small!!  Click mouse to exit...");
  50.         beepWait ();
  51.           return (0);
  52.       }
  53.  
  54.     if ((testzbufsiz = NewPtr (zbufsiz * 6)) == NULL)
  55.       {
  56.         give_msg ("\pBad choice for buffer size -- too big!!  Click mouse to exit...");
  57.         beepWait ();
  58.           return (0);
  59.       }
  60.  
  61.       DisposPtr (testzbufsiz);
  62.  
  63.     
  64.     for (i = 0; i < 3; ++i)
  65.         for (j = 0; j < 2; ++j)
  66.           {
  67.             if ((buf[i][j] = NewPtr (zbufsiz)) == NULL)
  68.               {
  69.                 give_msg ("\pFatal error allocating a merge buffer!  Click mouse to exit...");
  70.                 beepWait ();
  71.                 return (0);
  72.               }
  73.             else
  74.               {
  75.                   bufp[i][j] = buf[i][j];
  76.                   bufcount[i][j] = 0;
  77.               }
  78.           }
  79.     
  80.     return (1);
  81.   }
  82.  
  83.  
  84.